﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LY.Common;
using LY.DataAccess.Repository;
using LY.Entity;
using LY.Entity.PageSearch;
using LY.Entity.SearchEntity;
using LY.Interface;
using LY.Entity.Entities;
using System.Transactions;

namespace LY.Business.ServiceImpl
{
    public class RoleService : IRoleService
    {
        RoleRepository _repo;
        public RoleService()
        {
            _repo = new RoleRepository();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteRole(int id)
        {
            return _repo.DeleteRole(id);
        }

        public int DeleteS_Role(int id)
        {
            return _repo.DeleteS_Role(id);
        }

        public PagedList<S_Role> QueryRoleList(RoleSearch search, PageView view)
        {
            return _repo.QueryRoleList(search, view);
        }

        public List<S_Role> GetRoleList(int? ID)
        {
            return _repo.GetRoleList(ID);
        }

        public List<S_Role> GetAllRoleList()
        {
            return _repo.GetAllRoleList();
        }

        public S_Role GetRole(int? id)
        {
            return _repo.GetRole(id);
        }

        public int SaveRole(S_Role menu)
        {
            if (menu.ID <= 0)
            {
                //新增
                return (int)_repo.Insert(menu);
            }
            else
            {
                //编辑
                return (int)_repo.Update(menu);
            }
        }

        public int GiveAuthorization(string Authorization, int? id)
        {
            return _repo.GiveAuthorization(Authorization,id);
        }

        public int SaveRoleUser(string Users, int? id)
        {
            return _repo.SaveRoleUser(Users, id);
        }


    }
}
